import {
  ActiveUserByTenantReq,
  ActiveUserByTimeMap,
  ActiveUsersReq,
  AppPackageSubReqDto,
  AppPackageSubResp,
  UserActiveResp,
} from './model/userActivityAnalysisModel';
import { operationHttp } from '/@/utils/http/axios';

enum Api {
  GET_APP_PACKAGE_SUBSCRIPTION = '/v1/userActivity/appPackageSub',
  GET_USER_DAU_MAU = '/v1/userActivity/userActive',
  GET_ACTIVE_USERS_BY_TENANT = '/v1/userActivity/activeUsersByTenant',
  GET_ACTIVE_USERS_IN_TOTAL = '/v1/userActivity/activeUsersStatistic',
}

export const getAppPackageSubscription = (params: AppPackageSubReqDto) => {
  // 获取应用套餐订阅情况
  return operationHttp.post<AppPackageSubResp>({
    url: Api.GET_APP_PACKAGE_SUBSCRIPTION,
    params,
  });
};

export const getUserDauMau = () => {
  // 获取日活比例、月活比例、DAU/MAU
  return operationHttp.get<UserActiveResp>({ url: Api.GET_USER_DAU_MAU });
};

export const getActiveUsersByTenant = (params: ActiveUserByTenantReq) => {
  // 按租户获取用户活跃数
  return operationHttp.get<ActiveUserByTimeMap[]>({
    url: Api.GET_ACTIVE_USERS_BY_TENANT,
    params,
  });
};

export const getActiveUsersInTotal = (params: ActiveUsersReq) => {
  // 获取总用户活跃数
  return operationHttp.get<ActiveUserByTimeMap[]>({
    url: Api.GET_ACTIVE_USERS_IN_TOTAL,
    params,
  });
};
